package cs2340.g21.wms;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.LinkedList;
import java.io.IOException;
import java.io.Serializable;

/**
 * A class to represent an item and its associated tags, picture, and other info
 * @author Alexander
 * @version 1.0
 */
public class Item extends IOException implements Serializable{
    private String name;
    private SerializableBitmap picture;
    private SerializableLocation location;
    private String description;
    private List<String> tags;
    private List<Item> matches;
    private Category category;
    private int userId;
    private int id;
    private Calendar date;
    
    public Item(String name, SerializableBitmap picture, SerializableLocation location, String description, List<String> tags, Category category,
                Calendar date, int userId){
        this.name = name;
        this.picture = picture;
        this.location = location;
        this.category = category;
        this.description = description;
        this.tags = tags;
        this.date = date;
        this.matches = new ArrayList<Item>();
        this.userId = userId;
    }

    /**
     * @return name of this item
     */
    public String getName() {
        return name;
    }

    /**
     * @param name to be associated with this item
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return picture associated with this item
     */
    public SerializableBitmap getPicture() {
        return picture;
    }

    /**
     * @param picture to associate with this item
     */
    public void setPicture(SerializableBitmap picture) {
        this.picture = picture;
    }

    /**
     * @return location associated with this item
     */
    public SerializableLocation getLocation() {
        return location;
    }

    /**
     * @param location to be associated with this item
     */
    public void setLocation(SerializableLocation location) {
        this.location = location;
    }

    /**
     * @return this item's description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description to be associated with this item
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return this item's tags
     */
    public List<String> getTags() {
        return tags;
    }

    /**
     * @param tags sets tags associated with this item
     */
    public void setTags(List<String> tags) {
        this.tags = tags;
    }

    /**
     * @return enum category
     */
    public Category getCategory() {
        return category;
    }

    /**
     * @param category set which type of item this item is (see Category enum)
     */
    public void setCategory(Category category) {
        this.category = category;
    }

    /**
     * @return userId associated with this item
     */
    public int getUserId() {
        return userId;
    }

    /**
     * @param userId id of user associated with this item
     */
    public void setUserId(int userId) {
        this.userId = userId;
    }

    /**
     * @return date associated with this item
     */
    public Calendar getDate() {
        return date;
    }

    /**
     * @param date to associate with this item
     */
    public void setDate(Calendar date) {
        this.date = date;
    }

    /**
     * @return this item's id
     */
    public int getId() {
        return id;
    }
    
    /**
     * @param id to set as this item's id
     */
    public void setId(int id){
        this.id = id;
    }
    
    /**
     * Used to serialize item
     * @param out outputstream to which coordinator will be written
     * @throws IOException
     */
    private void writeObject(java.io.ObjectOutputStream out) throws IOException{
            out.defaultWriteObject();   
    }
    
    /**
     * Used to recreate item from an output stream
     * @param in inputstream from which coordinator will be read
     * @throws IOException
     * @throws ClassNotFoundException
     */
    private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException{
        in.defaultReadObject();
    }
    
    /**
     * @param i item to add to this items' matches list
     */
    public void addMatch( Item i ){
    	this.matches.add(i);
    }
    
    /**
     * @return the list of this item's matches
     */
    public List<Item> getMatches() {
    	return matches;
    }
}
